//package com.gudaomai.wuye.core;
//
//import java.io.IOException;
//import java.io.PrintWriter;
//
//import javax.servlet.ServletException;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//
//import org.apache.log4j.LogManager;
//import org.apache.log4j.Logger;
//import org.springframework.context.support.MessageSourceAccessor;
//import org.springframework.security.core.AuthenticationException;
//import org.springframework.security.core.SpringSecurityMessageSource;
//import org.springframework.security.web.AuthenticationEntryPoint;
//
//import com.gudaomai.wuye.common.CommonConstant;
//import com.gudaomai.wuye.entity.RetEntity;
//
///**
// * 这个入口点其实仅仅是被ExceptionTranslationFilter引用
// * 由此入口决定redirect、forward的操作
// * @author XueLiang
// * @date 2017年3月1日 上午10:20:39
// * @version 1.0
// */
//public class RestAuthenticationEntryPoint implements AuthenticationEntryPoint {
//
//    private static final Logger LOGGER = LogManager.getLogger(RestAuthenticationEntryPoint.class);
//    
//    protected MessageSourceAccessor messages = SpringSecurityMessageSource.getAccessor();
//    
//    @Override
//    public void commence(HttpServletRequest request, HttpServletResponse response,
//            AuthenticationException authException) throws IOException, ServletException {
//        LOGGER.warn("Authentication Failed: " + authException.getMessage());
//        RetEntity jsonResponse = new RetEntity();
//        jsonResponse.setRetCode(CommonConstant.RESULT_CODE_EXPECTATION_FAILED);
//        response.addHeader("Content-type", "application/json; charset=UTF-8");
//        response.setCharacterEncoding("UTF-8");
//        PrintWriter printWriter = response.getWriter();
//        printWriter.write(jsonResponse.toString());
//        printWriter.flush();
//        printWriter.close();
//    }
//}
